<%@include file="/html/library/init.jsp"%>

<portlet:renderURL var="updateBookURL">
	<portlet:param name="jspPage" value="/html/library/update.jsp" />
</portlet:renderURL>

<portlet:renderURL var="bookListURL">
	<portlet:param name="jspPage" value="/html/library/list.jsp" />
</portlet:renderURL>

<h1>
	<div>
		<div>
			<a href="<%= updateBookURL %>">Add new Book &raquo;</a>
		</div>
		<div>
			<a href="<%= bookListURL %>">Book List &raquo;</a>
		</div>
		<div>
			<a href="#" onclick="javascript:addBook();">Add Book Popup &raquo;</a>
		</div>
	</div>
</h1>
<hr/>
<portlet:actionURL var="searchBooksURL" name="<%= LibraryConstants.ACTION_SEARCH_BOOKS %>" />

<aui:form action="<%=searchBooksURL.toString()%>">
	<aui:input name="searchTerm" label="Enter Title to search" />
	<aui:input name="" type="submit" value="Search" />
</aui:form>
<aui:script>

	function addBook() {

		var ajaxURL = Liferay.PortletURL.createRenderURL();
		ajaxURL.setPortletId('<%=themeDisplay.getPortletDisplay().getRootPortletId()%>');
		ajaxURL.setParameter('jspPage', '/html/library/update.jsp');
		ajaxURL.setParameter('isPopup', true);
		ajaxURL.setWindowState('pop_up');

		AUI().use('liferay-util-window',function(A) {
			Liferay.Util.openWindow({
				dialog : {
					centered : true,
					modal : true,
					width : 600,
					height : 400,
					destroyOnHide : true
				},
				id : '<portlet:namespace/>editPortfolioPopup',
				title : 'Add Book',
				uri : ajaxURL
			});
		});	
	}
</aui:script>